package day03.practice;

import java.util.Random;
import java.util.Scanner;
/**
 * @author yangwenqi
 * @decs TODO
 * @date 2025/4/14
 */
//生成[a,b]区间的随机数
//random.nextInt((b-a)+1)+a
public class Practice04 {
    public static void main(String[] args) {
        Random random = new Random();
        int num=random.nextInt(100)+1;
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入一个1-100的数字:");
        int guess=sc.nextInt();
        int i=7;
        while(i>0){
            if(guess==num){
                System.out.println("恭喜你猜对了");
                break;
            }else if(guess>num){
                System.out.println("猜大了");
                System.out.println("请重新输入一个数字");
                guess=sc.nextInt();
            }else{
                System.out.println("猜小了");
                System.out.println("请重新输入一个数字");
                guess=sc.nextInt();
            }
            i--;
            if(i==0){
                System.out.println("你太笨了，下次再来吧");
            }
        }
    }
}
